-- Restador de exponentes

library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;

entity restador is
port(p,q: in std_logic_vector(7 downto 0);
	 dif,max: out std_logic_vector(7 downto 0);
	 sel: out std_logic);
end restador;

--p,q exponentes 
--dif = |p - q|
--max = max(p,q)
--sel seleccionar el mayor exponente

architecture behavior of restador is
begin
process(p,q)
variable s: std_logic_vector(7 downto 0);
begin
if(signed(p) > signed(q)) then
   s := signed(p) -signed(q);
   dif <= std_logic_vector(unsigned(s));
   max <= p;
   sel <= '0';
else
   s := signed(q) -signed(p);
   dif <= std_logic_vector(unsigned(s));
   max <= q;
   sel <= '1';
end if;
end process;
end behavior;
